<template>
  <el-form
    ref="ruleFormRef"
    :model="formInline"
    :rules="applyFormRules"
    label-width="82px"
  >
    <el-form-item label="广告账号" prop="account_id">
      <el-select
        v-model="formInline.account_id"
        placeholder="请选择广告账号"
        clearable
        filterable
        style="width: 100%"
      >
        <el-option
          v-for="item in accountOptions"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        />
      </el-select>
    </el-form-item>
  </el-form>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { applyFormRules } from "./utils/rule";
import type { AdClearApplyFormProps, SelectOption } from "./utils/types";

interface Props {
  formInline: AdClearApplyFormProps["formInline"];
  accountOptions?: Array<SelectOption>;
}

const props = withDefaults(defineProps<Props>(), {
  formInline: () => ({
    account_id: 0
  }),
  accountOptions: () => []
});

const ruleFormRef = ref();
const formInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script> 